using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 地点数据
/// </summary>
[Serializable]
public class PlaceData 
{
   public float Richness;//丰富度
   public float RichnessMax;//丰富度上限
   public float difficultyInCollection;//采集难度
   public float corrDifficultyInCollection;//采集难度修正
   public float basicSuccessRate;//基础成功率
   public float currentEvent;//当前事件成功率
   public float corrBasicSuccessRate;//基础成功率修正
   public float basicSuccessRateMax;//基础成功率最大值

   public float GetProperty(string propertyName)
   {
      switch (propertyName)
      {
         case "Richness":
            return Richness;
         case "RichnessMax":
            return RichnessMax;
         case "difficultyInCollection":
            return difficultyInCollection;
         case "corrDifficultyInCollection":
            return corrDifficultyInCollection;
         case "basicSuccessRate":
            return basicSuccessRate;
         case "currentEvent":
            return currentEvent;
         case "corrBasicSuccessRate":
            return corrBasicSuccessRate;
         case "basicSuccessRateMax":
            return basicSuccessRateMax;
         default:
            Debug.LogWarning($"找不到名为 {propertyName} 的地点属性");
            return 0;
      }
   }
}

public static class PlaceDataExtensions
{
   public static float GetAttributeValue(this PlaceData placeDatas, string objectType, string propertyName, PlayerStats playerStats = null, PlaceData placeData = null)
   {
      switch (objectType)
      {
         case "玩家":
            if (playerStats!= null)
            {
               return playerStats.GetPropertyValue(propertyName);
            }
            else
            {
               Debug.LogWarning("PlayerStats实例为空，无法获取属性值");
               return 0;
            }
         case "目标":
            if (playerStats!= null)
            {
               return playerStats.GetPropertyValue(propertyName);
            }
            else
            {
               Debug.LogWarning("PlayerStats实例为空，无法获取属性值");
               return 0;
            }
         case "地点":
            if (placeData!= null)
            {
               switch (propertyName)
               {
                  case "Richness":
                     return placeData.Richness;
                  case "RichnessMax":
                     return placeData.RichnessMax;
                  case "difficultyInCollection":
                     return placeData.difficultyInCollection;
                  case "corrDifficultyInCollection":
                     return placeData.corrDifficultyInCollection;
                  case "basicSuccessRate":
                     return placeData.basicSuccessRate;
                  case "currentEvent":
                     return placeData.currentEvent;
                  case "corrBasicSuccessRate":
                     return placeData.corrBasicSuccessRate;
                  case "basicSuccessRateMax":
                     return placeData.basicSuccessRateMax;
                  default:
                     Debug.LogWarning($"找不到名为 {propertyName} 的地点属性");
                     return 0;
               }
            }
            else
            {
               Debug.LogWarning("PlaceData实例为空，无法获取属性值");
               return 0;
            }
         default:
            Debug.LogWarning($"不支持的对象类型: {objectType}");
            return 0;
      }
   }
}
